home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / taskvb4 / form1.frm < prev    next >
Text File  |  1996-02-21  |  5KB  |  181 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   3075
  5.    ClientLeft      =   2850
  6.    ClientTop       =   2070
  7.    ClientWidth     =   7290
  8.    Height          =   3510
  9.    Left            =   2790
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3075
  12.    ScaleWidth      =   7290
  13.    Top             =   1695
  14.    Width           =   7410
  15.    Begin VB.ListBox List1 
  16.       Height          =   2790
  17.       Left            =   4860
  18.       TabIndex        =   3
  19.       Top             =   120
  20.       Width           =   2355
  21.    End
  22.    Begin VB.CommandButton UpArrow 
  23.       Caption         =   "Place to hold the up arrow icon"
  24.       DragIcon        =   "Form1.frx":0000
  25.       Height          =   315
  26.       Left            =   900
  27.       TabIndex        =   1
  28.       Top             =   1320
  29.       Visible         =   0   'False
  30.       Width           =   3195
  31.    End
  32.    Begin VB.CommandButton DownArrow 
  33.       Caption         =   "Place to hold the down arrow icon"
  34.       DragIcon        =   "Form1.frx":030A
  35.       Height          =   315
  36.       Left            =   900
  37.       TabIndex        =   0
  38.       Top             =   1740
  39.       Visible         =   0   'False
  40.       Width           =   3195
  41.    End
  42.    Begin MsghookLib.Msghook Msghook1 
  43.       Left            =   240
  44.       Top             =   2400
  45.       _version        =   65536
  46.       _extentx        =   1085
  47.       _extenty        =   979
  48.       _stockprops     =   0
  49.    End
  50.    Begin VB.Label Label1 
  51.       Caption         =   $"Form1.frx":0614
  52.       Height          =   1095
  53.       Left            =   180
  54.       TabIndex        =   2
  55.       Top             =   120
  56.       Width           =   4575
  57.    End
  58.    Begin VB.Menu PopUp 
  59.       Caption         =   "PopUp"
  60.       Visible         =   0   'False
  61.       Begin VB.Menu MenuFunction 
  62.          Caption         =   "Function 1"
  63.          Index           =   0
  64.       End
  65.       Begin VB.Menu MenuFunction 
  66.          Caption         =   "Function 2"
  67.          Index           =   1
  68.       End
  69.       Begin VB.Menu MenuFunction 
  70.          Caption         =   "-"
  71.          Index           =   2
  72.       End
  73.       Begin VB.Menu MenuFunction 
  74.          Caption         =   "The last super function"
  75.          Index           =   3
  76.       End
  77.    End
  78. End
  79. Attribute VB_Name = "Form1"
  80. Attribute VB_Creatable = False
  81. Attribute VB_Exposed = False
  82.  
  83. Option Explicit
  84.  
  85. Dim DownIcon As Integer
  86. Private Sub Form_Load()
  87.  
  88. Dim ltemplong As Long
  89.     
  90. 'Make sure the Explorer shell is running. If not, we can't use the taskbar
  91.     structBarData.lStructureSize = 36&
  92.     ltemplong = SHAppBarMessage(ABM_GETTASKBARPOS, structBarData)
  93.     If ltemplong <> 1 Then
  94.         Exit Sub
  95.     End If
  96.     
  97. 'Set up the data structure for the Shell_NotifyIcon function
  98.     structNotify.lStructureSize = 88&
  99.     structNotify.hWnd = Me.hWnd
  100.     structNotify.lID = 0&
  101.     structNotify.lFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
  102.     structNotify.lCallBackMessage = UM_TASKBARMESSAGE
  103.     structNotify.hIcon = DownArrow.DragIcon
  104.     structNotify.sTip = "A very happy tooltip!" & Chr$(0)
  105.     ltemplong = Shell_NotifyIcon(NIM_ADD, structNotify)
  106.     DownIcon = True
  107.     
  108. 'Setup the message blaster to call us when we
  109. 'get a message from the shell notify icon
  110.  Msghook1.HwndHook = Me.hWnd
  111.  Msghook1.Message(UM_TASKBARMESSAGE) = True
  112.       
  113.  
  114. End Sub
  115.  
  116.  
  117. Private Sub Form_Unload(Cancel As Integer)
  118.  
  119. Dim ltemplong As Long
  120.  
  121. 'Remove icon from the taskbar
  122.     ltemplong = Shell_NotifyIcon(NIM_DELETE, structNotify)
  123.  
  124. End Sub
  125.  
  126.  
  127. Private Sub MenuFunction_Click(Index As Integer)
  128.  
  129.     If Index = 3 Then
  130.         MsgBox "I really like the super function too!"
  131.     End If
  132.     
  133. End Sub
  134.  
  135.  
  136. Private Sub Msghook1_Message(ByVal msg As Long, ByVal wp As Long, ByVal lp As Long, result As Long)
  137.  
  138.     List1.AddItem lp, 0
  139.     
  140. Dim Okay As Long
  141.  
  142. 'When we get the left mouse button going up message, we'll change the icon
  143.     If lp = 514 Then
  144.         If DownIcon = True Then
  145.             DownIcon = False
  146.  
  147. 'Change icon to up arrow
  148.             structNotify.hIcon = UpArrow.DragIcon
  149.             structNotify.lFlags = NIF_ICON
  150.             Okay = Shell_NotifyIcon(NIM_MODIFY, structNotify)
  151. 'Change tip
  152.             structNotify.sTip = "A different happy tip!" & Chr$(0)
  153.             structNotify.lFlags = NIF_TIP
  154.             Okay = Shell_NotifyIcon(NIM_MODIFY, structNotify)
  155.         
  156.         Else
  157.         
  158.             DownIcon = True
  159.  
  160. 'Change icon to down arrow
  161.             structNotify.hIcon = DownArrow.DragIcon
  162.             structNotify.lFlags = NIF_ICON
  163.             Okay = Shell_NotifyIcon(NIM_MODIFY, structNotify)
  164. 'Change tip
  165.             structNotify.sTip = "Back to the original tip!" & Chr$(0)
  166.             structNotify.lFlags = NIF_TIP
  167.             Okay = Shell_NotifyIcon(NIM_MODIFY, structNotify)
  168.         End If
  169.             
  170.     End If
  171.     
  172.     
  173. 'When we get a right click, we'll pop up a menu
  174.     If lp = 517 Then
  175.         PopupMenu PopUp
  176.     End If
  177.      
  178. End Sub
  179.  
  180.  
  181.